import {
  VuexModule,
  Module,
  Mutation,
  getModule,
  Action
} from "vuex-module-decorators";
import store from "@/store";

export interface LoadingType {
  loading: false;
}

@Module({ dynamic: true, name: "loading", store })
export default class Loading extends VuexModule {
  private _loading = false;

  get loading() {
    return this._loading;
  }

  @Mutation
  START_LOADING(): void {
    this._loading = true;
  }

  @Mutation
  STOP_LOADING(): void {
    this._loading = false;
  }

  @Action({ commit: "START_LOADING" })
  StartRequesting() {
    return "";
  }

  @Action({ commit: "STOP_LOADING" })
  StopRequesting() {
    return "";
  }
}

export const LoadingModule = getModule(Loading);
